<html>
<head><meta charset="utf-8"><title>adding compiler version fields to Session? · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/adding.20compiler.20version.20fields.20to.20Session.3F.html">adding compiler version fields to Session?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="227325168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/adding%20compiler%20version%20fields%20to%20Session%3F/near/227325168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/adding.20compiler.20version.20fields.20to.20Session.3F.html#227325168">(Feb 22 2021 at 19:40)</a>:</h4>
<p>internally the compiler uses <code>option_env!("CFG_VERSION")</code> and <code>option_env!("CFG_RELEASE")</code> to look up version information at runtime (I'm not actually sure what makes these two distinct). should these become Version fields on the Session struct instead? specifically I'm looking at the deprecated-in-future lint, which looks up <code>CFG_RELEASE</code> every time it wants to check if a deprecated item is currently deprecated or not, which sounds like an unnecessary amount of I/O</p>



<a name="227325563"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/adding%20compiler%20version%20fields%20to%20Session%3F/near/227325563" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/adding.20compiler.20version.20fields.20to.20Session.3F.html#227325563">(Feb 22 2021 at 19:43)</a>:</h4>
<p>option_env! is a compile-time macro, so it's just expanding to something with type <code>Option&lt;&amp;'static str&gt;</code>. I don't think putting it in Session would be faster necessarily, but if there's some parsing work it might be good to cache that.</p>



<a name="227326347"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/adding%20compiler%20version%20fields%20to%20Session%3F/near/227326347" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/adding.20compiler.20version.20fields.20to.20Session.3F.html#227326347">(Feb 22 2021 at 19:47)</a>:</h4>
<p>ah, I didn't realize it wasn't actually looking up an env var. and yes, currently deprecated-in-future is parsing that string every time</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>